Crate gcc

Source
Expand description

A library for build scripts to compile custom C code

This library is intended to be used as a build-dependencies entry in Cargo.toml:

[build-dependencies]
gcc = "0.3"

The purpose of this crate is to provide the utility functions necessary to compile C code into a static archive which is then linked into a Rust crate. Configuration is available through the Build struct.

This crate will automatically detect situations such as cross compilation or other environment variables set by Cargo and will build code appropriately.

The crate is not limited to C code, it can accept any source code that can be passed to a C or C++ compiler. As such, assembly files with extensions .s (gcc/clang) and .asm (MSVC) can also be compiled.

§Examples

Use the Build struct to compile src/foo.c:

extern crate gcc;

fn main() {
    gcc::Build::new()
               .file("src/foo.c")
               .define("FOO", Some("bar"))
               .include("src")
               .compile("foo");
}

Modules§

  • A helper module to probe the Windows Registry when looking for windows-specific tools.

Structs§

  • BuildDeprecated
    Extra configuration to pass to gcc.
  • Represents an internal error that occurred, with an explaination.
  • Configuration used to represent an invocation of a C compiler.